package main

import (
	"gitee.com/wydcn/watcher/lib"
	"github.com/fsnotify/fsnotify"
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"log"
)

func main () {

	fBoby,err := ioutil.ReadFile("config.yml")
	if err != nil {
		log.Fatal(err)
	}
	var task []lib.Task
	yaml.Unmarshal(fBoby,&task)
	var done = make(chan bool)
	var eventBus = make(chan fsnotify.Event)
	log.Println("start watch")

	go lib.Start(task,done,eventBus)
	go  lib.HanderEvent(eventBus,task)
	log.Println("start loop")
	go  lib.TaskLoop()
	<-done
}


